package cug.xxs.jpa.domain;

import com.google.common.collect.Sets;
import lombok.Data;


import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;

@Entity
@Table(name = "tb_model")
@Data
public class Model implements Serializable {

    @Id
    private String id = UUID.randomUUID().toString();

    private String name = "";

    // 主要勘探层系
    private String mainExplorationLayer = "";

    // 油气藏类型
    private String gasReservoirType = "";

    // 沉积相带
    private String face = "";

    // 岩性
    private String lithology = "";

    // 物性特征
    private String property = "";

    private String field = "";

    // 储层特征
    private String reservoirFeature = "";
    // 勘探面积
    private String explorationArea = "";
    // 油藏埋深

    private String gasReservoirDepth = "";


    private String project = "";


    private String geographicPosition = "";

    private String structuralPosition = "";

    @OneToMany(mappedBy = "model", cascade = CascadeType.REMOVE)
    private Set<Well> wells = Sets.newLinkedHashSet();

    @OneToMany(mappedBy = "model", cascade = CascadeType.REMOVE)
    private Set<Layer> layers = Sets.newLinkedHashSet();

    @OneToMany(mappedBy = "model", cascade = CascadeType.REMOVE)
    @OrderBy("sequence asc")
    private Set<Fault> faults = Sets.newLinkedHashSet();

    public Model() {
        super();
        this.mainExplorationLayer = "";
        this.gasReservoirType = "";
        this.face = "";
        this.lithology = "";
        this.property = "";
        this.field = "";
        this.reservoirFeature = "";
        this.explorationArea = "";
        this.gasReservoirDepth = "";
        this.project = "";
        this.geographicPosition = "";
        this.structuralPosition = "";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Model model = (Model) o;
        return id.equals(model.id) &&
                name.equals(model.name) &&
                Objects.equals(mainExplorationLayer, model.mainExplorationLayer) &&
                Objects.equals(gasReservoirType, model.gasReservoirType) &&
                Objects.equals(face, model.face) &&
                Objects.equals(lithology, model.lithology) &&
                Objects.equals(property, model.property) &&
                Objects.equals(field, model.field) &&
                Objects.equals(reservoirFeature, model.reservoirFeature) &&
                Objects.equals(explorationArea, model.explorationArea) &&
                Objects.equals(gasReservoirDepth, model.gasReservoirDepth) &&
                Objects.equals(project, model.project) &&
                Objects.equals(geographicPosition, model.geographicPosition) &&
                Objects.equals(structuralPosition, model.structuralPosition);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, mainExplorationLayer, gasReservoirType, face, lithology, property, field, reservoirFeature, explorationArea, gasReservoirDepth, project, geographicPosition, structuralPosition);
    }
}
